<?php
namespace Qcloud;
use Qcloud\QQSMS\SmsMultiSender;
use Qcloud\QQSMS\SmsSingleSender;

class SMS {


	private $appid = "1400058359";

	private $appkey = "fb8e2d901c0faada42c291f5880da43d";

	private $codeTemplate = 125274;

	private $alarmTemplate = 74223;

	private $signMinnor = 34273;

	public function __construct() {

	}

	public function sendValidateionCode($phone, $code, $minutes = 15) {

		try {

			$sender = new SmsSingleSender($this->appid, $this->appkey);

			$params = [$code];

			$result = $sender->sendWithParam("86", $phone, $this->codeTemplate, $params, "", "", "");

			$rsp = json_decode($result);

			//print_r($rsp);

			//echo $rsp->errmsg;

			return $rsp->errmsg;

		} catch (\Exception $e) {

			return var_dump($e);
		}
	}

	public function sendAlarm($phone, $site, $alarm) {

		try {

			$sender = new SmsMultiSender($this->appid, $this->appkey);

			$params = [$site, $alarm];

			$phoneArray = explode(',', $phone);

			$result = $sender->sendWithParam("86", $phoneArray, $this->alarmTemplate, $params, "", "", "");

			$rsp = json_decode($result);

			//print_r($rsp);

			//echo $rsp->errmsg;

			return $rsp->errmsg;

		} catch (\Exception $e) {

			return var_dump($e);
		}

	}

}
?>